package com.surprise.bweb;

import java.util.List;

import org.elasticsearch.common.collect.Lists;

import com.surprise.bweb.vo.SelectItemVO;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;

@AllArgsConstructor(access = AccessLevel.PRIVATE)
public enum UserRole {
	ADMIN(1, "ADMIN"), // 管理员  
	MALL(2, "MALL"), // 商场人员
	SHOP(3, "SHOP"); // 零售
	public int id;
	public String name;
	
	public static UserRole getRoleByType(int type) {
		for (UserRole role : values()) {
			if (role.id == type) {
				return role;
			}
		}
		return null;
	}
	
	public static List<SelectItemVO> getAllRoles() {
		List<SelectItemVO> ret = Lists.newArrayList();
		for (UserRole role : values()) {
			ret.add(new SelectItemVO(role.name, role.id + ""));
		}
		return ret;
	}
}
